import { useMouse } from './hooks/useMouse';
/*
  学习目标：复用组件逻辑的三种方式-👍自定义hooks
*/

export default function App() {
  return (
    <div>
      App
      <hr />
      <Header />
      <Main />
      <Footer />
    </div>
  );
}

function Main() {
  const { mouse, handleMouseMove } = useMouse();
  return (
    <div>
      我是Main -
      <h1 onMouseMove={handleMouseMove}>
        {mouse.x} - {mouse.y}
      </h1>
    </div>
  );
}

function Footer() {
  const { mouse, handleMouseMove } = useMouse();
  return (
    <h1 onMouseMove={handleMouseMove}>
      我是Footer - {mouse.x} - {mouse.y}
    </h1>
  );
}

function Header() {
  const { mouse, handleMouseMove } = useMouse();

  return (
    <div onMouseMove={handleMouseMove}>
      <h1>
        x: {mouse.x} - y: {mouse.y}
      </h1>
    </div>
  );
}
